﻿using System;
using awsomeSyntezator.PipeLine.Filters;

namespace awsomeSyntezator.PipeLine.Oscilators
{
	class Wind : Oscilator
	{
		private WhiteNoise white;
		private RedNoise red;
        private Filter filter;
		private double scaleLo;
		private double scaleHi;

		public Wind(float resonance, int strenght): base(0, 0, strenght)
		{
			white = new WhiteNoise(0,1);
			red = new RedNoise(Options.noiseDensity, 1);
			filter = new HighCutOffFilter(Options.noiseEffectCutOffFrequency, Options.effectResonance);
			//filter = new LowCutOffFilter(Options.noiseEffectCutOffFrequency, Options.effectResonance);
			type = 0;
			scaleLo = 290;
			scaleHi = Options.noiseEffectCutOffFrequency;


		}

		public override double getSample(int n, double sample)
		{
			filter.setParams((float)(((red.getSample(n, sample) + 1.0) / 2.0) * (scaleHi - scaleLo) + scaleLo), Options.effectResonance);
			return filter.getSample(n,white.getSample(n,sample));
		}
	}
}